<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let arr = [2,3,5,10,20];

    //计算数组元素之和
    let result = arr.reduce((prev, cur) => {
      //计算和
      return prev + cur;
    }, 0);

    console.log(result);

  </script>
</body>
</html>